#============================================================
#	PlayerMove
#============================================================
# @datetime: 2022-4-26 00:59:06
#============================================================
class_name PlayerMove
extends PlayerBaseState


var _can_jump : bool = false
var _can_jump_timer = create_timer()


#(override)
func enter():
	# 刚爬楼梯出来不能立即跳跃
	if get_last_state() == PlayerStateBlackboard.States.CLIMB_STAIRS:
		_can_jump = false
		_can_jump_timer.start(2)
		Logger.info(self, [
			'--------------'
			, _can_jump_timer.time_left
		])
	Logger.info(self, [get_last_state()])


#(override)
func state_process(_arg0):
	input_fall()
	
	if get_last_state() == PlayerStateBlackboard.States.CLIMB_STAIRS:
		Logger.info(self, [
			'--------------'
			, _can_jump_timer.time_left
		])
	
	
	if (Input.is_action_just_pressed(InputKey.UP)
		or _can_jump_timer.time_left == 0
#		or get_move_controller().is_falling()
	):
#		Logger.info(self, [
#			Input.is_action_just_pressed(InputKey.UP)
#			, _can_jump_timer.time_left <= 0
#		])
		_can_jump = true
	
	if _can_jump and input_jump():
		switch_to(PlayerStateBlackboard.States.JUMP)
	elif input_attack():
		switch_to(PlayerStateBlackboard.States.ATTACK)
	elif input_climb_stairs():
		switch_to(PlayerStateBlackboard.States.CLIMB_STAIRS)
	elif input_climb_wall():
		switch_to(PlayerStateBlackboard.States.CLIMB_WALL)
	elif not input_move():
		switch_to(PlayerStateBlackboard.States.IDLE)
	


